#ifndef MAIN_MEMORY_H
#define MAIN_MEMORY_H

#include <QVector>

#include "node.h"

#include "ip/fabrics.h"

class MainMemory : public Node
{
public:
    typedef struct ReadReq
    {
        std::complex<float> data;
        int addr;
        int pid;
        int sb_addr;
        int ain_addr;
        bool clr;
        int cas_count;
    } ReadReq;

    typedef struct WriteReq
    {
        std::complex<float> data;
        int addr;
        int cas_count;
    } WriteReq;

    explicit MainMemory(Node *parent,
                        int cas, int multiplexer, int size);

    void preload(const QVector<AllocOp> &aops);

    NodeTaskList tasks() const override;

    void task_check_read();
    void task_check_write();

    int cas, multiplexer;

    ChannelLoadReqFabricReceiver *request_receiver;
    ChannelLoadFabricSender *load_sender;
    ChannelStoreFabricReceiver *store_receiver;

    QVector<std::complex<float>> reg_data;
    QList<ReadReq> queue_read;
    QList<WriteReq> queue_write;
};

#endif // MAIN_MEMORY_H
